package com.ruoyi.web.controller.ydz;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.DoctorDisease;
import com.ruoyi.web.service.IDoctorDiseaseService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医生疾病Controller
 * 
 * @author why
 * @date 2025-05-13
 */
@Controller
@RequestMapping("/ydz/doctorDisease")
@Api(tags = "医生疾病")
public class DoctorDiseaseController extends BaseController
{
    private String prefix = "ydz/doctorDisease";

    @Autowired
    private IDoctorDiseaseService doctorDiseaseService;

    @RequiresPermissions("ydz:doctorDisease:view")
    @GetMapping()
    public String doctorDisease()
    {
        return prefix + "/doctorDisease";
    }

    /**
     * 查询医生疾病列表
     */
    @RequiresPermissions("ydz:doctorDisease:list")
    @PostMapping("/list")
    @ResponseBody
    @ApiOperation("查询医生疾病列表")
    public TableDataInfo list(DoctorDisease doctorDisease)
    {
        startPage();
        List<DoctorDisease> list = doctorDiseaseService.selectDoctorDiseaseList(doctorDisease);
        return getDataTable(list);
    }

    /**
     * 导出医生疾病列表
     */
    @RequiresPermissions("ydz:doctorDisease:export")
    @Log(title = "医生疾病", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    @ApiOperation("导出医生疾病列表")
    public AjaxResult export(DoctorDisease doctorDisease)
    {
        List<DoctorDisease> list = doctorDiseaseService.selectDoctorDiseaseList(doctorDisease);
        ExcelUtil<DoctorDisease> util = new ExcelUtil<DoctorDisease>(DoctorDisease.class);
        return util.exportExcel(list, "医生疾病数据");
    }

    /**
     * 新增医生疾病
     */
    @GetMapping("/add")
    @ApiOperation("新增医生疾病")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存医生疾病
     */
    @ApiOperation("新增保存医生疾病")
    @RequiresPermissions("ydz:doctorDisease:add")
    @Log(title = "医生疾病", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DoctorDisease doctorDisease)
    {
        return toAjax(doctorDiseaseService.insertDoctorDisease(doctorDisease));
    }

    /**
     * 修改医生疾病
     */
    @ApiOperation("修改医生疾病")
    @RequiresPermissions("ydz:doctorDisease:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        DoctorDisease doctorDisease = doctorDiseaseService.selectDoctorDiseaseById(id);
        mmap.put("doctorDisease", doctorDisease);
        return prefix + "/edit";
    }

    /**
     * 修改保存医生疾病
     */
    @ApiOperation("修改保存医生疾病")
    @RequiresPermissions("ydz:doctorDisease:edit")
    @Log(title = "医生疾病", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DoctorDisease doctorDisease)
    {
        return toAjax(doctorDiseaseService.updateDoctorDisease(doctorDisease));
    }

    /**
     * 删除医生疾病
     */
    @ApiOperation("删除医生疾病")
    @RequiresPermissions("ydz:doctorDisease:remove")
    @Log(title = "医生疾病", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(doctorDiseaseService.deleteDoctorDiseaseByIds(ids));
    }
}
